#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__author__ = "Administrator"
__name__="mult_event"
__date__="2016/9/14"
__time__="17:03"
"""
import multiprocessing
import time

def wait_for_event(e):
    """ wait for the event to be set before doing anything """
    print("wait_for_event:starting")
    e.wait()
    print("wait_for_event:e.is_set()-->" + str(e.is_set()))

def wait_for_event_timeout(e,t):
    """ wait t seconds and then timeout """
    print("wait_for_event_timeout:starting")
    e.wait(t)
    print("wait_for_event_timeout:e.is_set()-->"+str(e.is_set()))

if __name__=='__name__':
    e = multiprocessing.Event()
    w1 = multiprocessing.Process(name='block',target=wait_for_event,args=(e,))
    w1.start()

    time.sleep(3)
    e.set()
    print "main:event is set"
